﻿using Abp.Domain.Entities.Auditing;
using MyCompanyName.AbpZeroTemplate.Authorization.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCompanyName.AbpZeroTemplate.Prm.Project
{
    public class ProjectTask : FullAuditedEntity<int>
    {
        /// <summary>
        /// 使用任务成员的圈权限
        /// 默认为true
        /// </summary>
        public virtual bool UsedMemberQuan { get; set; }

        /// <summary>
        /// 项目ID
        /// </summary>
        public int ProjectId { get; set; }
        /// <summary>
        /// 工艺路线
        /// </summary>
        public string Route { get; set; }

        /// <summary>
        /// 步骤
        /// </summary>
        public string Step { get; set; }
        /// <summary>
        /// 所属
        /// </summary>
        public string Dept { get; set; }
        /// <summary>
        /// 问题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 年份
        /// </summary>
        public int Year { get; set; }
        /// <summary>
        /// 周次
        /// </summary>
        public int Week { get; set; }

        /// <summary>
        /// 标签
        /// </summary>
        public string Tags { get; set; }


        /// <summary>
        /// 是否已完成
        /// </summary>
        public bool IsFinsh { get; set; }
        /// <summary>
        /// 是否已归档
        /// </summary>
        public bool IsArchived { get; set; }

        /// <summary>
        /// 计划完成时间
        /// </summary>
        public DateTime PlanFinshTime { get; set; }

        /// <summary>
        /// 实际完成时间
        /// </summary>
        public DateTime ActualFinshTime { get; set; }
        /// <summary>
        /// 问题可见范围
        /// </summary>
        public VisibleRange Range { get; set; }
        /// <summary>
        /// 优先级
        /// </summary>
        public int Priority { get; set; }
    }

    /// <summary>
    /// 可见范围
    /// </summary>
    public enum VisibleRange
    {
        项目内共享 = 10,
        指定成员 = 20
    }


    /// <summary>
    /// 项目任务附件 答案
    /// </summary>
    public class ProjectTaskAttachment : FullAuditedEntity<int>
    {
        public int ProjectTaskId { get; set; }
        public string Name { get; set; }
        public string FullUrl { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Note { get; set; }

        public int ProjectId { get; set; }
    }

    /// <summary>
    /// 项目任务成员
    /// </summary>
    public class ProjectTaskMember : FullAuditedEntity<int>
    {
        public int ProjectTaskId { get; set; }

        [ForeignKey("ProjectTaskId")]
        public virtual ProjectTask ProjectTask { get; set; }

        public long UserId { get; set; }
        [ForeignKey("UserId")]
        public virtual User User { get; set; }
        public int ProjectId { get; set; }
    }

    //public class ProjectTaskRole : FullAuditedEntity<int>
    //{
    //    public int ProjectTaskId { get; set; }

    //    [ForeignKey("ProjectTaskId")]
    //    public virtual ProjectTask ProjectTask { get; set; }

    //    public int ProjectRoleId { get; set; }
    //    [ForeignKey("ProjectRoleId")]
    //    public virtual ProjectRoleInfo ProjectRoleInfo { get; set; }
    //    public int ProjectId { get; set; }
    //}

    /// <summary>
    /// 项目任务关注者
    /// </summary>
    public class ProjectTaskFollower : FullAuditedEntity<int>
    {
        /// <summary>
        /// 任务Id
        /// </summary>
        public int ProjectTaskId { get; set; }
        [ForeignKey("ProjectTaskId")]
        public virtual ProjectTask ProjectTask { get; set; }

        /// <summary>
        /// 用户Id
        /// </summary>
        public long UserId { get; set; }
        [ForeignKey("UserId")]
        public virtual User User { get; set; }
        public int ProjectId { get; set; }
    }


    /// <summary>
    /// 子任务
    /// </summary>
    public class ProjectTaskSubTask : FullAuditedEntity<int>
    {
        /// <summary>
        /// 所属任务Id
        /// </summary>
        public int ProjectTaskId { get; set; }
        [ForeignKey("ProjectTaskId")]
        public virtual ProjectTask ProjectTask { get; set; }

        /// <summary>
        /// 子任务名称
        /// </summary>
        public string SubTitle { get; set; }

        public int OrderNo { get; set; }

        /// <summary>
        /// 是否已完成
        /// </summary>
        public bool Completed { get; set; }

        public int ProjectId { get; set; }
    }
}
